| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var Layout = function() { |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Get default section layout. |
||
| 5 | */ |
||
| 6 | this.getDefaultSectionLayout = function(index) { |
||
| 7 | return $.ajax({ |
||
| 8 | url: '/wp-admin/admin-ajax.php?action=wpdfi_get_default_layout', |
||
| 9 | method: 'POST', |
||
| 10 | data: { |
||
| 11 | index: index, |
||
| 12 | include_delete: true |
||
| 13 | }, |
||
| 14 | }) |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Get related layout of a section, related layout include taxonomies, image upload and image size. |
||
| 19 | */ |
||
| 20 | this.getRelatedSectionLayout = function(sectionIndex, postType) { |
||
| 21 | return $.ajax({ |
||
| 22 | url: '/wp-admin/admin-ajax.php?action=wpdfi_get_related_layout', |
||
| 23 | method: 'POST', |
||
| 24 | data: { |
||
| 25 | section_index: sectionIndex, |
||
| 26 | post_type: postType |
||
| 27 | }, |
||
| 28 | }) |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Get errors wrapper layout. |
||
| 33 | */ |
||
| 34 | this.getErrorListingWrapperLayout = function() { |
||
| 35 | return '<ul class="error-list">%error-list-markup%</ul>'; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get single error listing layout. |
||
| 40 | */ |
||
| 41 | this.getErrorSingleListingLayout = function(errorContent) { |
||
| 42 | return '<li class="single-error">' + errorContent + '</li>'; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Get delete button layout. |
||
| 47 | */ |
||
| 48 | this.getDeleteButtonLayout = function() { |
||
| 49 | return '<a href="#" class="btn-remove">-</a>'; |
||
| 50 | } |
||
| 51 | |||
| 52 | } |
||
| 53 | |||
| 54 | export default Layout; |